home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / mainbvb4 / mailnblk.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-10-01  |  8.1 KB  |  254 lines

  1. VERSION 4.00
  2. Begin VB.Form Form1 
  3.    Appearance      =   0  'Flat
  4.    BackColor       =   &H00C0C0C0&
  5.    Caption         =   "Non-Blocking Sample"
  6.    ClientHeight    =   3675
  7.    ClientLeft      =   3360
  8.    ClientTop       =   3105
  9.    ClientWidth     =   5640
  10.    BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  11.       Name            =   "MS Sans Serif"
  12.       Size            =   8.25
  13.       Charset         =   0
  14.       Weight          =   700
  15.       Underline       =   0   'False
  16.       Italic          =   0   'False
  17.       Strikethrough   =   0   'False
  18.    EndProperty
  19.    ForeColor       =   &H80000008&
  20.    Height          =   4080
  21.    Left            =   3300
  22.    LinkTopic       =   "Form1"
  23.    ScaleHeight     =   3675
  24.    ScaleWidth      =   5640
  25.    Top             =   2760
  26.    Width           =   5760
  27.    Begin VB.TextBox Text4 
  28.       Appearance      =   0  'Flat
  29.       Height          =   1575
  30.       Left            =   600
  31.       MultiLine       =   -1  'True
  32.       TabIndex        =   7
  33.       Top             =   1440
  34.       Width           =   4215
  35.    End
  36.    Begin VB.CommandButton Command1 
  37.       Appearance      =   0  'Flat
  38.       BackColor       =   &H80000005&
  39.       Caption         =   "Send Message"
  40.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  41.          Name            =   "MS Sans Serif"
  42.          Size            =   8.25
  43.          Charset         =   0
  44.          Weight          =   400
  45.          Underline       =   0   'False
  46.          Italic          =   0   'False
  47.          Strikethrough   =   0   'False
  48.       EndProperty
  49.       Height          =   375
  50.       Left            =   1440
  51.       TabIndex        =   3
  52.       Top             =   3120
  53.       Width           =   2175
  54.    End
  55.    Begin VB.TextBox Text3 
  56.       Appearance      =   0  'Flat
  57.       Height          =   285
  58.       Left            =   1560
  59.       TabIndex        =   2
  60.       Top             =   840
  61.       Width           =   2175
  62.    End
  63.    Begin VB.TextBox Text2 
  64.       Appearance      =   0  'Flat
  65.       Height          =   285
  66.       Left            =   1560
  67.       TabIndex        =   1
  68.       Top             =   480
  69.       Width           =   2175
  70.    End
  71.    Begin VB.TextBox Text1 
  72.       Appearance      =   0  'Flat
  73.       Height          =   285
  74.       Left            =   1560
  75.       TabIndex        =   0
  76.       Top             =   120
  77.       Width           =   2175
  78.    End
  79.    Begin MailLib.mMail Mail1 
  80.       Left            =   0
  81.       Top             =   1440
  82.       _Version        =   327680
  83.       _ExtentX        =   847
  84.       _ExtentY        =   847
  85.       _StockProps     =   0
  86.       Blocking        =   0   'False
  87.       Debug           =   0
  88.       Host            =   ""
  89.       Timeout         =   0
  90.       ConnectType     =   0
  91.       PopPort         =   110
  92.       SmtpPort        =   25
  93.    End
  94.    Begin VB.Label Label4 
  95.       Alignment       =   1  'Right Justify
  96.       Appearance      =   0  'Flat
  97.       BackColor       =   &H00C0C0C0&
  98.       Caption         =   "Message:"
  99.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  100.          Name            =   "MS Sans Serif"
  101.          Size            =   8.25
  102.          Charset         =   0
  103.          Weight          =   400
  104.          Underline       =   0   'False
  105.          Italic          =   0   'False
  106.          Strikethrough   =   0   'False
  107.       EndProperty
  108.       ForeColor       =   &H80000008&
  109.       Height          =   255
  110.       Left            =   480
  111.       TabIndex        =   8
  112.       Top             =   1200
  113.       Width           =   975
  114.    End
  115.    Begin VB.Label Label3 
  116.       Alignment       =   1  'Right Justify
  117.       Appearance      =   0  'Flat
  118.       BackColor       =   &H00C0C0C0&
  119.       Caption         =   "Subject:"
  120.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  121.          Name            =   "MS Sans Serif"
  122.          Size            =   8.25
  123.          Charset         =   0
  124.          Weight          =   400
  125.          Underline       =   0   'False
  126.          Italic          =   0   'False
  127.          Strikethrough   =   0   'False
  128.       EndProperty
  129.       ForeColor       =   &H80000008&
  130.       Height          =   255
  131.       Left            =   240
  132.       TabIndex        =   6
  133.       Top             =   840
  134.       Width           =   1215
  135.    End
  136.    Begin VB.Label Label2 
  137.       Alignment       =   1  'Right Justify
  138.       Appearance      =   0  'Flat
  139.       BackColor       =   &H00C0C0C0&
  140.       Caption         =   "SMTP Server:"
  141.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  142.          Name            =   "MS Sans Serif"
  143.          Size            =   8.25
  144.          Charset         =   0
  145.          Weight          =   400
  146.          Underline       =   0   'False
  147.          Italic          =   0   'False
  148.          Strikethrough   =   0   'False
  149.       EndProperty
  150.       ForeColor       =   &H80000008&
  151.       Height          =   255
  152.       Left            =   120
  153.       TabIndex        =   5
  154.       Top             =   480
  155.       Width           =   1335
  156.    End
  157.    Begin VB.Label Label1 
  158.       Alignment       =   1  'Right Justify
  159.       Appearance      =   0  'Flat
  160.       BackColor       =   &H00C0C0C0&
  161.       Caption         =   "To:"
  162.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  163.          Name            =   "MS Sans Serif"
  164.          Size            =   8.25
  165.          Charset         =   0
  166.          Weight          =   400
  167.          Underline       =   0   'False
  168.          Italic          =   0   'False
  169.          Strikethrough   =   0   'False
  170.       EndProperty
  171.       ForeColor       =   &H80000008&
  172.       Height          =   255
  173.       Left            =   240
  174.       TabIndex        =   4
  175.       Top             =   120
  176.       Width           =   1215
  177.    End
  178. Attribute VB_Name = "Form1"
  179. Attribute VB_Creatable = False
  180. Attribute VB_Exposed = False
  181.     Dim iState As Integer
  182. Private Sub Command1_Click()
  183.     On Error GoTo Some_Err
  184.     'validate entries
  185.     If Text1.Text = "" Or Text2.Text = "" Or Text3.Text = "" Then
  186.         MsgBox "Please fill in all values.", vbExclamation, "Missing Value"
  187.         Exit Sub
  188.     End If
  189.     Mail1.Debug = 1
  190.     'create a new message
  191.     Mail1.Action = MailActionNewMessage
  192.     Mail1.Date = Format$(Now, "ddd, dd mmm yyyy hh:mm:ss")
  193.     '
  194.     'Your user friendly name
  195.     Mail1.From = "Your Name"
  196.     '
  197.     'The return e-mail address
  198.     Mail1.EMailAddress = "you@yourdomain.com"
  199.     '
  200.     'the lucky recipient
  201.     Mail1.To = Text1.Text
  202.     Mail1.Subject = Text3.Text
  203.     'create the headers for the message
  204.     '
  205.     Mail1.Body(0) = Text4.Text
  206.     'basic host configuration
  207.     Mail1.Blocking = False
  208.     Mail1.Host = Text2.Text
  209.     Mail1.ConnectType = 0 'MailConnectTypeSMTP
  210.     'send the message
  211.     Command1.Enabled = False
  212.     MousePointer = 11
  213.     iState = MailActionConnect
  214.     Mail1.Action = MailActionConnect
  215.     'the Done event of the Mail control handles the
  216.     'next actions
  217.     Exit Sub
  218. Some_Err:
  219.     MsgBox CStr(Err)
  220.     On Error Resume Next
  221.     Mail1.Action = MailActionDisconnect
  222.     MousePointer = 0
  223.     Command1.Enabled = True
  224. End Sub
  225. Private Sub Mail1_AsyncError(ByVal ErrorCode As Integer, ByVal ErrorMsg As String)
  226.     MsgBox "AsyncError: " & CStr(ErrorCode) & " - " & ErrorMsg
  227.     On Error Resume Next
  228.     iState = MailActionDisconnect
  229.     Mail1.Action = iState
  230. End Sub
  231. Private Sub Mail1_Debug(ByVal Message As String)
  232.     Debug.Print Message
  233. End Sub
  234. Private Sub Mail1_Done()
  235.     Select Case iState
  236.         Case MailActionConnect
  237.             Me.Caption = "Connected. Writing message..."
  238.             Mail1.Flags = MailDstIsHost
  239.             iState = MailActionWriteMessage
  240.             Mail1.Action = iState
  241.         Case MailActionWriteMessage
  242.             Me.Caption = "Message sent. Disconnecting..."
  243.             iState = MailActionDisconnect
  244.             Mail1.Action = iState
  245.         Case MailActionDisconnect
  246.             Me.Caption = "Disconnected!"
  247.             MousePointer = 0
  248.             Command1.Enabled = True
  249.         Case Else
  250.             MousePointer = 0
  251.             Command1.Enabled = True
  252.     End Select
  253. End Sub
  254.